'***************************************************************** '** Example to illustrate the speed of transferring data ** '** over the bus in binary format from the 236 SMU. The ** '** program then combines all of the bytes into individual ** '** readings. Requires CEC IEEE-488 Interface. ** '** ** '** Author: Jonathan L. Tucker ** '** Date: August 25, 1992 ** '** Copyright (c) 1992, Keithley Instruments, Inc. ** '***************************************************************** DECLARE SUB IBMINIT.INST () DECLARE SUB GPIB.INIT () ' 236BIN.BAS**************************************************** ' $INCLUDE: 'ieeeqb.bi' SCREEN 0 CLS DIM byte236(1000) AS LONG ' Declare byte storage DIM lowbyte AS LONG ' Declare LOWBYTE variable DIM midbyte AS LONG ' Declare MIDBYTE variable DIM hibyte AS LONG ' Declare HIBYTE variable DIM expbyte AS LONG ' Declare EXPBYTE variable DIM statusbyte AS INTEGER ' Declare STATUSBYTE variable CALL GPIB.INIT ' Initialize the GPIB Interface '----- Perform an IBM Format Transfer ------ CALL IBMINIT.INST ' Initialize the SMU CLS PRINT : PRINT "Printing results of IBM Transfer" CALL transmit("MLA TALK 05", status%) ' Put SMU in Talk Mode CALL rarray(byte236(0), 4002, length%, status%) ' Read Binary Data PRINT "Number of bytes = "; length% ' Print #Bytes transferred PRINT "Number of Readings = "; (length% - 2) / 4 ' Compute # readings cmd$ = "N0X" ' Place SMU in Standby CALL send(5, cmd$, status%) shift8& = 2 ^ 8 ' Compute shift function shift16& = 2 ^ 16 PRINT '------ Convert data data.seg = VARSEG(byte236(0)) ' Point to data segment data.ptr = VARPTR(byte236(0)) ' Point to data offset DEF SEG = data.seg ' Define data segment FOR x% = 0 TO ((length% - 2) / 4) - 1 PRINT "Reading #"; x% lowbyte = PEEK(data.ptr + (4 * x% + 2)) midbyte = PEEK(data.ptr + (4 * x% + 3)) * shift8& hibyte = PEEK(data.ptr + (4 * x% + 4)) * shift16& expbyte = PEEK(data.ptr + (4 * x% + 5)) AND &HF ' Compute lowbyte, midbyte, ' hibyte, and exponent statusbyte = (PEEK(data.ptr + 4 * x% + 5) AND &H10) \ 16 ' Measure I or V '------ statusbyte returns a 0 if: V-Measure '------ statusbyte returns a 1 if: I-Measure PRINT "Statusbyte in HEX = "; HEX$(statusbyte) PRINT "Lowbyte in HEX = "; HEX$(lowbyte) PRINT "Midbyte in HEX = "; HEX$(midbyte) PRINT "Hibyte in HEX = "; HEX$(hibyte) PRINT "Expbyte in HEX = "; HEX$(expbyte) '------ Compute reading value based on Measure I or V measure236 = (lowbyte + midbyte + hibyte) IF statusbyte THEN measure236 = measure236 * (10 ^ -14 * (10 ^ expbyte)) ELSE measure236 = measure236 * (10 ^ -5 * (10 ^ expbyte)) END IF PRINT "Measured value = "; measure236 PRINT NEXT x% END SUB GPIB.INIT GPIB.INIT: '********* INITIALIZE GPIB INTERFACE ************************** CALL Initialize(21, 0)'Init Controller cmd$ = "U0X" CALL send(5, cmd$, status%) RD$ = SPACE$(30) CALL Enter(RD$, length%, 5, status%) PRINT "Model # and Firmware Revision is "; RD$ END SUB SUB IBMINIT.INST REM***************** INITIALIZE THE SMU's ********************** cmd$ = "J0X" CALL send(5, cmd$, status%) SLEEP 1 cmd$ = "F1,1X" ' Source I, Measure V, Sweep CALL send(5, cmd$, status%) cmd$ = "Y4X" ' No terminator CALL send(5, cmd$, status%) cmd$ = "L10,2X" ' Compliance=10VDC, 11VDC range CALL send(5, cmd$, status%) cmd$ = "Q1,1E-3,5E-3,1E-3,8,500X" ' Create sweep CALL send(5, cmd$, status%) cmd$ = "G4,4,2X" ' Display Measure, IBM Binary CALL send(5, cmd$, status%) cmd$ = "N1X" ' Operate CALL send(5, cmd$, status%) cmd$ = "H0X" ' Trigger CALL send(5, cmd$, status%) '----- Monitor Poll Byte to determine sweep end DO CALL spoll(5, pollbyte%, status%) LOOP UNTIL (pollbyte% AND 2) = 2 END SUB